﻿
using UnityEngine;
using Cysharp.Threading.Tasks;
namespace Client.Base
{
    public class FsmInitPatch : PatchState
    {
        public override void OnEnter()
        {
             LoadAsset();
        }
        private async void LoadAsset()
        {
             this.Log("[Patch] FsmInitPatch.");
         
            //string lan = LocalCache.Lanuage;
            //var opt = Resources.LoadAsync<TextAsset>($"lan_{lan}");
            // await opt.ToUniTask();
            //TextAsset text = opt.asset as TextAsset;
            //Localization.SetSource(text.text);
            var opt = Resources.LoadAsync<GameObject>("UIPatch");
            await opt.ToUniTask();
            GameObject clone = GameObject.Instantiate(opt.asset) as GameObject;
            clone.transform.SetParent(UIRoot.Instance.GetLayer(UILayer.Patch), false);
            UIPatch patch = clone.GetComponent<UIPatch>();
            PatchHandle.Instance.SetUIPatch(patch);
            PatchHandle.Instance.ShowProgressMessage("正在初始化...");
            //PatchHandle.Instance.Change<FsmNetConfig>();
            PatchHandle.Instance.Change<FsmInitPackage>();
        }
    }

}
